﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using EnvironmentManagerSystem.Utility;
using System.IO;
using System.Diagnostics;

namespace EnvironmentManagerSystem.HuanJing
{
    public partial class PDF1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (!IsPostBack)
            //{
                //Button1.Attributes.Add("onclick", "window.open('http://127.0.0.1:8881/converttopdf?file=d:/aork/aost.xls','winname','width=300,height=200,top=0,left=0');return false");
                //Button1.Attributes.Add("onclick", "window.open('http://125.211.221.215:8881/converttopdf?file=e:/aork/aost.xls','winname','width=300,height=200,top=0,left=0');return false");
                //bool b = true;
                //FileInfo f = new FileInfo("d:/aork/aost.pdf");
                //b = f.Exists;
                //if (b)
                //{
                //    OfficeHelper.DownFile(this, "d:/aork/aost.pdf");
                //}
                //else
                //{
                //    Jscript.Alert("cuocuocuo", this);
                //}
                //
            //}
        }
        #region MyRegion
                    //string Url = "http://127.0.0.1:8881/converttopdf?file=d:/aork/aost.xls";
            //Bn1.OnClientClick = "window.open('" + Url + "');";
            //Bn1.PostBackUrl = "http://127.0.0.1:8881/converttopdf?file=d:/aork/aost.xls";
           
      
            //Bn1.OnClientClick = "window.open('" + Url + "','_blank','menubar=no,status=no,scrollbars=no,top=0,left=0,toolbar=no,width=720,height=520'); return false;";
       
        //[DllImport("shell32.dll")]
        //public static extern int ShellExecute(IntPtr hwnd, StringBuilder lpszOp, StringBuilder lpszFile, StringBuilder lpszParams, StringBuilder lpszDir, int FsShowCmd);
        //protected void button1_onclick(object sender, EventArgs e)
        //{
            
        //}

            //ShellExecute(IntPtr.Zero, new StringBuilder("Open"), new StringBuilder("soffice.exe"), new StringBuilder("--headless -convert-to pdf d:/backup/cost.xls -outdir d:/backup"), null, 1);

            //soffice.exe --headless -convert-to pdf e:\work\cost.xls -outdir e:\work

            // ShellExecute(IntPtr.Zero, new StringBuilder("Open"), new StringBuilder("soffice.exe"), new StringBuilder("--headless -convert-to pdf e:\\work\\cost.xls -outdir w:\\work"), null, 1);


            //ShellExecute(IntPtr.Zero, new StringBuilder("Open"), new StringBuilder("soffice.exe"), new StringBuilder("--headless -convert-to pdf d:\\backup\\cost.xls -outdir d:\\backup"), new StringBuilder(@"d:/"), 1);

            //if (EnvironmentManagerSystem.BLL.ExcelPDF.XLSConvertToPDF("D:/text.xls", "D:/testD.pdf"))
            //{
            //    Jscript.Alert("DOC转换成功！", this);
            //}
            //else
            //{
            //    Jscript.Alert("对不起，转换失败", this);
            //}

            //}
    
            //protected void Button1_Click(object sender, EventArgs e)

            //{
            //string a = "d:\aork\aost.xls";
            //Process.Start("http://127.0.0.1:8881/converttopdf?file="+a);
            //string b = "d:\\backup\\cost.pdf";
            //OfficeHelper.DownFile(this, b);   
  


            //string url = "http://www.baidu.com";
            //this.Response.Redirect(url);

            

            //好使
            //http://127.0.0.1:8881/converttopdf?file=e:\work\cost.xls
            //string a = "d:/backup/cost.xls";

            //string aa="cost.xls";
            //string a = "d:\backup"+aa;
            //string b = "http://127.0.0.1:8881/converttopdf?file=" + a;
            //Response.Write("<script language=javascript>window.open('" + b + "');</script>");

            //string b = "http://127.0.0.1:8881/converttopdf?file=e:\aork\aost.xls";
            //Response.Write("<script language=javascript>window.open('" + b + "');</script>");

            //string aa = "e:\aork\aost.xls";
            //string b = "http://127.0.0.1:8881/converttopdf?file="+ aa;
            //Process.Start("<script language=javascript>window.open('" + b + "');</script>");

            //好使

            //afwindow.showModelessDialog

            //string b = "http://127.0.0.1:8881/converttopdf?file=d:\\aork\\aost.xls";

            ///_blank

            
            
            ////
            //string b = "http://127.0.0.1:8881/converttopdf?file=e:/aork/aost.xls";
            //this.Response.Write("<script language=javascript>window.open('" + b + "')</script>");
            ///



//            有什么问题请到<a href='/bbs/index.asp?boardid=2'>论坛</a>中发表<br>
//<!-- http://www./ -->
//<!-- http://bbs./ -->
//<!-- 把下面代码放到<body>区域中 -->

//<form>
//<div align="center">
//<input type="button" Value="打开新窗口" 
//ONCLICK="window.open('index.htm','Sample','toolbar=yes,location=no,directories=no,status=no,menubar=yes,scrollbars=no,resizable=no,copyhistory=yes,width=300,height=200,left=100,top=100')">
//</form> 

//<!--说明：将其中的链接文件test.htm改为你的路径，窗口参数如下： 

//toolbar=yes, 显示工具条
//location=yes,显示网址栏
//directories=no,导航条
//status=no,状态条
//menubar=yes,菜单
//scrollbars=yes,滚动条
//resizable=no,是否可以改变大小
//copyhistory=yes,历史按钮
//width=300,宽
//height=200'高
//left=100,距离左边100
//top=100,距离顶端100-->


//<a href="http://www.dlcom.org/js/">网页特效集-耽恋免费资源站</a> 


            //string showOpen = " <script   language= 'javascript '> window.open( '" + b + " ') </script> ";
            //if (!IsClientScriptBlockRegistered("clientScript"))
            //    RegisterClientScriptBlock("clientScript", showOpen);

            //Page.RegisterStartupScript("open", @"<script language=JavaScript> window.open( '"+b+" '); </script> ");
            //Thread.Sleep(20000);//休眠1000是一秒/毫秒 单位                

            //string ab = "d:/aork/aost.pdf";
            //OfficeHelper.DownFile(this, ab);

            //Page.RegisterStartupScript("open", @"<script language=JavaScript> window.open( '"+b+" '); </script> ");
            //Page.RegisterStartupScript("StartUP", @"<script language=JavaScript> window.open( '" + b + " ','_blank'); </script> ");




            //string showOpen = " <script   language= 'javascript '> window.open( '"+b+" ') </script> "; 
            //if(!IsClientScriptBlockRegistered("clientScript"))
            //    RegisterClientScriptBlock("clientScript",showOpen);


            ///
            //Response.Write("<script language=javascript>window.open('" + b + "');</script>");
            //string url = "http://www.baidu.com";
            //this.Response.Redirect(b);
            //this.Response.Redirect("<script language=javascript>window.open('" + b + "');</script>");

        //}
        #endregion

        protected void Button1_Click(object sender, EventArgs e)
        {

            Label1.Text = "sdfdsfdsfds";
            string Url = "http://127.0.0.1:8881/converttopdf?file=d:/aork/aost.xls";
            //string Url = "http://125.211.221.215:8881/converttopdf?file=e:/aork/aost.xls";
            //Button1.OnClientClick = "window.open('" + Url + "');";
            Process.Start(Url);
            
            bool b = true;
            FileInfo f = new FileInfo("d:\\aork\\aost.pdf");
            b = f.Exists;
            if (b)
            {
                OfficeHelper.DownFile(this, "d:\\aork\\aost.pdf");
            }
            else
            {
                Jscript.Alert("文件未生成，请5秒后再次点击下载！", this);
            }

 

            //Response.Write("window.open('" + Url + "');");
            
         
            //OfficeHelper.DownFile(this, "d:/aork/aost.pdf");
        }
    }
}
